export function getUrlParam (name) {
  var paramIndex = window.location.href.indexOf('?')
  if (paramIndex !== -1) {
    var parameter = window.location.href.substring(paramIndex)
    var reg = new RegExp('(^|[&|?])' + name + '=([^&]*)(&|$)'); // 构造一个含有目标参数的正则表达式对象
    var r = parameter.match(reg); // 匹配目标参数
  }

  if (r != null) return unescape(r[2]); return null; // 返回参数值
}
export function getOS () {
  var userAgent = ('navigator' in window && 'userAgent' in navigator && navigator.userAgent.toLowerCase()) || ''
  // var vendor = 'navigator' in window && 'vendor' in navigator && navigator.vendor.toLowerCase() || ''
  var appVersion = ('navigator' in window && 'appVersion' in navigator && navigator.appVersion.toLowerCase()) || ''

  // if (/mac/i.test(appVersion)) return 'MacOSX'
  // if (/win/i.test(appVersion)) return 'windows'
  // if (/linux/i.test(appVersion)) return 'linux'
  if (/iphone/i.test(userAgent) || /ipad/i.test(userAgent) || /ipod/i.test(userAgent) || /^apple$/.test(userAgent)) return 'ios'
  if (/android/i.test(userAgent)) return 'android'
  if (/win/i.test(appVersion) && /phone/i.test(userAgent)) return 'windowsPhone'
}
